import Operator from "./Operator";
import { RC } from "../config/RC";
import User from "../entities/User";

class BuildFriendOperation extends Operator {
    public async execute(): Promise<RC> {
        try {
            const userId: string = this.args.getProperty('userId');
            const friendId: string = this.args.getProperty('friendId');
            console.log(userId);
            const bl = await User.addFriend(userId,friendId);
            if(bl == true)
            {
                return RC.SUCCESS;
            }else
            {
                return RC.FRIENDCREATE_FAILURE;
            }

        } catch (error) {
            // 处理异常情况
            console.error('Error checking group existence:', error);
            return RC.INTERNAL_ERROR;
        }
    }
}

export default BuildFriendOperation;